//
//  FANUserAccountModel.swift
//  Weibo - Swift
//
//  Created by user on 16/4/19.
//  Copyright © 2016年 user. All rights reserved.
//

import UIKit

class FANUserAccountModel: NSObject,NSCoding {
    
    /*
    "access_token" = "2.00jaRlwBd7tdpB576abce0f362CDID";
    "expires_in" = 157679999;
    "remind_in" = 157679999;
    uid = 1784429361;
    */
    
    var access_token:String?
    
    var expires_in:NSTimeInterval = 0{
        
        didSet{
            
            expiresDate = NSDate(timeIntervalSinceNow: expires_in)
        }
    }
    
    var expiresDate:NSDate?
    
    var remind_in:String?
    
    var uid:String?
    
    var name:String?
    
    var avatar_large:String?
    
    init(dict:[String:AnyObject]) {
        
        super.init()
        
        setValuesForKeysWithDictionary(dict)
        
    }
    //解档
    required init?(coder aDecoder: NSCoder){
        
        uid = aDecoder.decodeObjectForKey("uid") as? String
        access_token = aDecoder.decodeObjectForKey("access_token") as? String
        name = aDecoder.decodeObjectForKey("name") as? String
        avatar_large = aDecoder.decodeObjectForKey("avatar_large") as? String
        expires_in = aDecoder.decodeDoubleForKey("expires_in")
        remind_in = aDecoder.decodeObjectForKey("remind_in") as? String
        expiresDate = aDecoder.decodeObjectForKey("expiresDate") as? NSDate
        
    }
    //存档
    func encodeWithCoder(aCoder: NSCoder){
        
        aCoder.encodeObject(uid, forKey: "uid")
        aCoder.encodeObject(access_token, forKey: "access_token")
        aCoder.encodeObject(name, forKey: "name")
        aCoder.encodeObject(avatar_large, forKey: "avatar_large")
        aCoder.encodeDouble(expires_in, forKey: "expires_in")
        aCoder.encodeObject(remind_in, forKey: "remind_in")
        aCoder.encodeObject(expiresDate, forKey: "expiresDate")

    }
    
   
    
    

}
